package com.sky.mapper;


import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.entity.DishFlavor;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DishMapper {
    List<Dish> getDishList(@Param("categoryId") Long categoryId,@Param("name")String name);

    @AutoFill(OperationType.INSERT)
    void addDish(Dish dish);


    void addFlavors(List<DishFlavor> flavors);

    Page<DishVO> getDishPage(DishPageQueryDTO dishPageQueryDTO);

   List<Long> findDishStatusUseBatch(List<Long> ids);


    void deleteDishByDishIdsBatch(List<Long> ids);

    void deleteFlavorsByDishIdsBatch(List<Long> ids);


    @Select("select * from dish where id = #{id}")
    Dish getDishById(Long id);

    @Select("select * from dish_flavor where dish_id = #{id}")
    List<DishFlavor> getDishFlavors(Long id);

    @AutoFill(OperationType.UPDATE)
    void updateDish(Dish dish);


    @Select("select * from dish where category_id = #{categoryId} and status = 1")
    List<Dish> getDishWithEnableStatusByCategoryId(Dish dish);

    @Select("select * from dish where category_id = #{id}")
    List<Dish> getDishs(Long id);
}
